﻿Imports DTO
Imports System.Data.OleDb

Public Class ThanhLySachDAO
    Public Function LayDanhSachThanhLySach() As List(Of ThanhLySachDTO)
        DataProvider.OpenConnecttion()
        Dim dsTLS As New List(Of ThanhLySachDTO)
        Dim sql As String = "select MaThanhLySach,MaNhanVien,NgayThanhLy,MaChiTietThanhLy from THANHLYSACH"
        Dim reader As OleDbDataReader
        reader = DataProvider.ExecSelect(sql)

        While reader.Read()
            Dim tlsDto As New ThanhLySachDTO
            tlsDto.MaThanhLySach = reader.GetInt32(0)
            tlsDto.MaNhanVien = reader.GetInt32(1)
            tlsDto.NgayThanhLy = reader.GetDateTime(2)
            tlsDto.MaChiTietThanhLy = reader.GetInt32(3)
            dsTLS.Add(tlsDto)
        End While

        DataProvider.CloseConnect()
        Return dsTLS
    End Function

    Public Function ThemThanhLaySach(ByVal sql As String) As Integer
        DataProvider.OpenConnecttion()
        Dim kq As Integer = DataProvider.ExecInsert(sql)
        DataProvider.CloseConnect()
        Return kq
    End Function

End Class
